package com.chuantou.yuba.util;

import android.content.Context;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.MotionEvent;

import com.android.volley.toolbox.NetworkImageView;
import com.chuantou.yuba.api.to.TrendsImageTO;

/**
 * 单张图片控件
 * 
 * @author Administrator
 * 
 */
public class TrendsImageView extends NetworkImageView {
	private TrendsImageTO mImage;

	public TrendsImageView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
	}

	public TrendsImageView(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public TrendsImageView(Context context) {
		super(context);
	}

	@Override
	public boolean onTouchEvent(MotionEvent event) {

		switch (event.getAction()) {
		case MotionEvent.ACTION_DOWN:
			Drawable drawable = getDrawable();
			if (drawable != null) {
				drawable.mutate().setColorFilter(Color.GRAY, PorterDuff.Mode.MULTIPLY);
			}
			break;
		case MotionEvent.ACTION_MOVE:
			break;
		case MotionEvent.ACTION_CANCEL:
		case MotionEvent.ACTION_UP:
			Drawable drawableUp = getDrawable();
			if (drawableUp != null) {
				drawableUp.mutate().clearColorFilter();
			}
			break;
		}

		return super.onTouchEvent(event);
	}

	public void setImage(TrendsImageTO image) {
		this.mImage = image;
	}
	
	public TrendsImageTO getImage(){
		return mImage;
	}

}
